from functools import reduce
from pypbc import *

class Node:
    u=[]
    def __init__(self,nodeType,value,index):
        self.type = nodeType
        self.value = value #for leaf ,value=attr,eles value = kx
        self.child = []
        self.poly = []
        self.index = index
        self.isRoot = False

    def appendChild(self,child):
        self.child.append(child)
        if (child.type == 'attr'):
            Node.u.append(child.value)

    def getY(self,x):
        result = reduce(lambda a,b: a*x+b,self.poly)
        return result

    def Root(self):
        self.isRoot=True

